<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    
    function foo(x,y,z) {
      console.log(x+y+z);
    }

    function hyCurrying(fn) {
      function curryFn(...args) {
        
        if (args.length >= fn.length) {
          fn(...args)
        } else {
          return function(...newArgs) {
            return curryFn(...args.concat(newArgs))
          }
        }
      }
      return curryFn
    }

    var fooCurry = hyCurrying(foo)
    fooCurry(10)(20)(30)
  </script>
</body>
</html>